import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
import BusinessList from '../views/BusinessList.vue'
import BusinessInfo from '../views/BusinessInfo.vue'
import Login from '../views/Login.vue'
import Orders from '../views/Orders.vue'
import UserAddress from '../views/UserAddress.vue'
import Payment from '../views/Payment.vue'
import OrderList from '../views/OrderList.vue'
import AddUserAddress from '../views/AddUserAddress.vue'
import EditUserAddress from '../views/EditUserAddress.vue'
import Register from '../views/Register.vue'
import PasswordChange from '../views/PasswordChange.vue'
import PersonalCenter from '../views/PersonalCenter.vue'
import BusinessManage from '../views/BusinessManage.vue'
import AddFood from '../views/AddFood.vue'
import EditFood from '../views/EditFood.vue'
import StoreManagement from '../views/StoreManagement.vue'
import AddStore from '../views/AddStore.vue'
import EditStore from '../views/EditStore.vue'
import Discover from '../views/Discover.vue'
// 钱包相关页面
import Wallet from '../views/Wallet.vue'
import WalletRecharge from '../views/WalletRecharge.vue'
import WalletWithdraw from '../views/WalletWithdraw.vue'
import WalletTransactions from '../views/WalletTransactions.vue'
import WalletPayment from '../views/WalletPayment.vue'
import WalletFreezeDetail from '../views/WalletFreezeDetail.vue'


Vue.use(VueRouter)

const routes = [{
	path: '/',
	name: 'Home',
	component: Index
}, {
	path: '/index',
	name: 'Index',
	component: Index
}, {
	path: '/businessList',
	name: 'BusinessList',
	component: BusinessList
}, {
	path: '/businessInfo',
	name: 'BusinessInfo',
	component: BusinessInfo
}, {
	path: '/login',
	name: 'Login',
	component: Login
}, {
	path: '/orders',
	name: 'Orders',
	component: Orders
}, {
	path: '/userAddress',
	name: 'UserAddress',
	component: UserAddress
}, {
	path: '/payment',
	name: 'Payment',
	component: Payment
}, {
	path: '/orderList',
	name: 'OrderList',
	component: OrderList
}, {
	path: '/addUserAddress',
	name: 'AddUserAddress',
	component: AddUserAddress
}, {
	path: '/editUserAddress',
	name: 'EditUserAddress',
	component: EditUserAddress
}, {
	path: '/register',
	name: 'Register',
	component: Register
}, {
	path: '/passwordChange',
	name: 'PasswordChange',
	component: PasswordChange
}, {
	path: '/personalCenter',
	name: 'PersonalCenter',
	component: PersonalCenter
}, {
	path: '/businessmanage',
	name: 'BusinessManage',
	component: BusinessManage
}, {
	path: '/addFood',
	name: 'AddFood',
	component: AddFood
}, {
	path: '/editFood',
	name: 'EditFood',
	component: EditFood
}, {
	path: '/storeManagement',
	name: 'StoreManagement',
	component: StoreManagement
}, {
	path: '/addStore',
	name: 'AddStore',
	component: AddStore
}, {
	path: '/editStore',
	name: 'EditStore',
	component: EditStore

}, {
	path: '/discover',
	name: 'Discover',
	component: Discover
}, {
	// 钱包相关路由
	path: '/wallet',
	name: 'Wallet',
	component: Wallet
}, {
	path: '/walletRecharge',
	name: 'WalletRecharge',
	component: WalletRecharge
}, {
	path: '/walletWithdraw',
	name: 'WalletWithdraw',
	component: WalletWithdraw
}, {
	path: '/walletTransactions',
	name: 'WalletTransactions',
	component: WalletTransactions
}, {
	path: '/walletPayment',
	name: 'WalletPayment',
	component: WalletPayment
}, {
	path: '/walletFreezeDetail',
	name: 'WalletFreezeDetail',
	component: WalletFreezeDetail
}]

//解决重复路由报异常问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

export default router